#include <cstdio>

using namespace std;

typedef long long LL;

const int N = 5e5 + 10;

int q[N], temp[N];

int n;
LL res;

void mergeSort(int l, int r)
{
	if (l >= r) return;
	
	int mid = l + r >> 1;
	
	mergeSort(l, mid);
	mergeSort(mid + 1, r);
	
	int i = l, j = mid + 1, t = 0;
	
	while (i <= mid && j <= r)
	{
		if (q[j] >= q[i]) temp[t ++ ] = q[i ++ ];
		else 
		{
			res += mid - i + 1;
			temp[t ++ ] = q[j ++ ];
		}
	}
	
	while (i <= mid) temp[t ++ ] = q[i ++ ];
	while (j <= r) temp[t ++ ] = q[j ++ ];
	
	for (int j1 = 0, j2 = l; j2 <= r; j2 ++ , j1 ++ ) q[j2] = temp[j1];
}

int main()
{
	scanf("%d", &n);
	
	for (int i = 0; i < n; i ++ ) scanf("%d", &q[i]);
	
	mergeSort(0, n - 1);
	
	printf("%lld", res);
	
	return 0;
}